package cn.com.guage.arrays;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class ArraysTest {

	public static void main(String[] args) {
		int[] array = new int[] { 1, 2, 3 };
		System.out.println(Arrays.toString(array)); // [1, 2, 3]
		
		int[][] deepArray = new int[][]{{1, 3},{2, 4}};
		System.out.println(Arrays.toString(deepArray)); //[[I@1540e19d, [I@677327b6]
		System.out.println(Arrays.deepToString(deepArray)); //[[1, 3], [2, 4]]
		
		
		array = new int[5];
		Arrays.fill(array, 2);
		System.out.println(Arrays.toString(array)); //[2, 2, 2, 2, 2]

		array = new int[5];
		Arrays.fill(array, 1, 4, 2); //部分填充
		System.out.println(Arrays.toString(array));//[0, 2, 2, 2, 0]
		
		array = new int[]{3, 10, 4, 0, 2};
		Arrays.sort(array);
		System.out.println(Arrays.toString(array)); //[0, 2, 3, 4, 10]

		array = new int[]{3, 10, 4, 0, 2};
		Arrays.parallelSort(array); //和sort相比是这个是并行的
		System.out.println(Arrays.toString(array)); //[0, 2, 3, 4, 10]

		array = new int[]{3, 10, 4, 0, 2};
		Arrays.sort(array, 0, 4); //部分排序
		System.out.println(Arrays.toString(array)); //[0, 3, 4, 10, 2]
		
		int[] array2 = new int[]{3, 10, 4, 0, 2};
		System.out.println(Arrays.asList(array2).contains(3)); //false

		Integer arr[] = new Integer[]{3, 10, 4, 0, 2};
		System.out.println(Arrays.asList(arr).contains(3)); //true
		int[] intarray = {1, 2, 3, 4, 5};
	    //List<Integer> list = Arrays.asList(intarray); 编译通不过
	    List<int[]> list = Arrays.asList(intarray);
	    System.out.println(list.get(0));
	    
	    int a [] ={1,2,3};
	    List<Integer> ilist = Arrays.stream(a).boxed().collect(Collectors.toList());
	    		System.out.println(ilist);
	    
	   // List<Integer> list3 = Ints.asList(intArray);
	}

}
